home *** CD-ROM | disk | FTP | other *** search
/ Tech Win 1995 November / CD [TECH_B].bin / tech_b / delphi / trial / disk4 / doc.pak / TYPINFO.INT < prev    next >
Encoding:
Text File  |  1995-08-08  |  3.9 KB  |  136 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Delphi Visual Component Library                 }
  4. {                                                       }
  5. {       Copyright (c) 1995 Borland International        }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. unit TypInfo;
  10.  
  11. {$N+,S-}
  12.  
  13. interface
  14.  
  15. uses Classes, SysUtils;
  16.  
  17. type
  18.  
  19.   TTypeKind = (tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat,
  20.     tkString, tkSet, tkClass, tkMethod);
  21.   TTypeKinds = set of TTypeKind;
  22.  
  23.   TOrdType = (otSByte, otUByte, otSWord, otUWord, otSLong);
  24.  
  25.   TFloatType = (ftSingle, ftDouble, ftExtended, ftComp);
  26.  
  27.   TMethodKind = (mkProcedure, mkFunction);
  28.   TParamFlags = set of (pfVar, pfConst, pfArray);
  29.  
  30.   PTypeInfo = ^TTypeInfo;
  31.   TTypeInfo = record
  32.     Kind: TTypeKind;
  33.     Name: string;
  34.    {TypeData: TTypeData}
  35.   end;
  36.  
  37.   PTypeData = ^TTypeData;
  38.   TTypeData = packed record
  39.     case TTypeKind of
  40.       tkUnknown: ();
  41.       tkInteger, tkChar, tkEnumeration, tkSet: (
  42.         OrdType: TOrdType;
  43.         case TTypeKind of
  44.           tkInteger, tkChar, tkEnumeration: (
  45.             MinValue: Longint;
  46.             MaxValue: Longint;
  47.             case TTypeKind of
  48.               tkInteger, tkChar: ();
  49.               tkEnumeration: (
  50.                 BaseType: PTypeInfo;
  51.                 NameList: string));
  52.           tkSet: (
  53.             CompType: PTypeInfo));
  54.       tkFloat: (
  55.         FloatType: TFloatType);
  56.       tkString: (
  57.         MaxLength: Byte);
  58.       tkClass: (
  59.         ClassType: TClass;
  60.         ParentInfo: PTypeInfo;
  61.         PropCount: SmallInt;
  62.         UnitName: string
  63.        {PropData: TPropData});
  64.       tkMethod: (
  65.         MethodKind: TMethodKind;
  66.         ParamCount: Byte;
  67.         ParamList: array[0..1023] of Char
  68.        {ParamList: array[1..ParamCount] of
  69.           record
  70.             Flags: TParamFlags;
  71.             ParamName: string;
  72.             TypeName: string;
  73.           end;
  74.         ResultType: string});
  75.   end;
  76.  
  77.   TPropData = packed record
  78.     PropCount: Word;
  79.     PropList: record end;
  80.    {PropList: array[1..PropCount] of TPropInfo}
  81.   end;
  82.  
  83.   PPropInfo = ^TPropInfo;
  84.   TPropInfo = packed record
  85.     PropType: PTypeInfo;
  86.     GetProc: Pointer;
  87.     SetProc: Pointer;
  88.     StoredProc: Pointer;
  89.     Index: SmallInt;
  90.     Default: Longint;
  91.     NameIndex: SmallInt;
  92.     Name: string;
  93.   end;
  94.  
  95.   TPropInfoProc = procedure(PropInfo: PPropInfo) of object;
  96.  
  97.   PPropList = ^TPropList;
  98.   TPropList = array[0..16379] of PPropInfo;
  99.  
  100. const
  101.   tkProperties = [tkInteger..tkClass];
  102.   tkMethods    = [tkMethod];
  103.   tkAny        = [tkUnknown..tkMethod];
  104.  
  105. { Property access routines }
  106.  
  107. function GetTypeData(TypeInfo: PTypeInfo): PTypeData;
  108.  
  109. function GetEnumName(TypeInfo: PTypeInfo; Value: Integer): PString;
  110. function GetEnumValue(TypeInfo: PTypeInfo; const EnumName: string): Integer;
  111.  
  112. function GetPropInfo(TypeInfo: PTypeInfo; const PropName: string): PPropInfo;
  113. procedure GetPropInfos(TypeInfo: PTypeInfo; PropList: PPropList);
  114. function GetPropList(TypeInfo: PTypeInfo; TypeKinds: TTypeKinds;
  115.   PropList: PPropList): Integer;
  116.  
  117. function IsStoredProp(Instance: TObject; PropInfo: PPropInfo): Boolean;
  118.  
  119. function GetOrdProp(Instance: TObject; PropInfo: PPropInfo): Longint;
  120. procedure SetOrdProp(Instance: TObject; PropInfo: PPropInfo;
  121.   Value: Longint);
  122.  
  123. function GetStrProp(Instance: TObject; PropInfo: PPropInfo): string;
  124. procedure SetStrProp(Instance: TObject; PropInfo: PPropInfo;
  125.   const Value: string);
  126.  
  127. function GetFloatProp(Instance: TObject; PropInfo: PPropInfo): Extended;
  128. procedure SetFloatProp(Instance: TObject; PropInfo: PPropInfo;
  129.   Value: Extended);
  130.  
  131. function GetMethodProp(Instance: TObject; PropInfo: PPropInfo): TMethod;
  132. procedure SetMethodProp(Instance: TObject; PropInfo: PPropInfo;
  133.   const Value: TMethod);
  134.  
  135. implementation
  136.